﻿// Copyright (c) Inossem. All rights reserved.
// Licensed under the LGPL-3.0 license. See LICENSE file in the project root for full license information.
using NuGet.Packaging;
using NuGet.ProjectManagement;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;

namespace DWF.Studio.NuGetManagement
{
    /// <summary>
    /// 项目上下文
    /// </summary>
    public class ProjectContext : INuGetProjectContext
    {
        private List<string> logs = new List<string>();

        public List<string> GetLogs()
        {
            return logs;
        }

        public void Log(MessageLevel level, string message, params object[] args)
        {
            Console.WriteLine(message);
            var formattedMessage = String.Format(message, args);
            logs.Add(formattedMessage);
        }

        public FileConflictAction ResolveFileConflict(string message)
        {
            logs.Add(message);
            Console.WriteLine(message);
            return FileConflictAction.Ignore;
        }


        public PackageExtractionContext PackageExtractionContext
        {
            get;
            set;
        }

        public NuGet.ProjectManagement.ExecutionContext ExecutionContext
        {
            get;
        }

        public XDocument OriginalPackagesConfig
        {
            get;
            set;
        }

        public ISourceControlManagerProvider SourceControlManagerProvider
        {
            get;
            set;
        }

        public void ReportError(string message)
        {
            Console.WriteLine(message);
            logs.Add(message);
        }

        public NuGetActionType ActionType
        {
            get; set;
        }

        public Guid OperationId
        {
            get; set;
        }
    }
}
